package com.shaoshaohuo.app.framework;

import android.os.Environment;

import com.shaoshaohuo.app.SshApplication;
import com.shaoshaohuo.app.utils.SdCardHelper;

import java.io.File;

/**
 * Created by yusonglin on 2015/7/9.
 * Description:
 */
public class DirManager {

    private static final String ROOT_NAME = "Shaoshaohuo";

    public static String getLogFile(String tag, int i) {
        return getAppLogDirectory() + tag + File.separator + ROOT_NAME+"Log_" + i + ".log";
    }

    public static String getAppLogDirectory() {
        String logPath = Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED) ? SshApplication
                        .getContext().getExternalFilesDir("") + File.separator + "log" + File.separator : ROOT_NAME
                        + File.separator + "log" + File.separator;
        if (!SdCardHelper.isDirExist(logPath)) {
            File file = new File(logPath);
            file.mkdirs();
        }
        return logPath;
    }
    
    public static String getAudioDirectory() {
        String logPath = Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED) ? SshApplication
                        .getContext().getExternalFilesDir("") + File.separator + "audio" + File.separator : ROOT_NAME
                        + File.separator + "audio" + File.separator;
        if (!SdCardHelper.isDirExist(logPath)) {
            File file = new File(logPath);
            file.mkdirs();
        }
        return logPath;
    }

}
